package de.uv.kilter.core;

import java.util.List;

import de.uv.kilter.exception.InfiniteLoopException;
import de.uv.kilter.exception.InvalidDataException;
import de.uv.kilter.exception.NotInitializedException;

public interface ICore 
{
	/**
	 * This method enables notification of any completed iteration.
	 * Therefore any class, implementing the interface {@link IIterationCompletedListener} 
	 * can be registered using this method.
	 * 
	 * @param listener - the listener to be notified
	 */
	public void addIterationCompletedListener(IIterationCompletedListener listener);
	
	/**
	 * This method removes the given registered listener. 
	 * The listener will not be notified any longer.
	 * 
	 * @param listener - the listener to be removed
	 */
	public void removeIterationCompletedListener(IIterationCompletedListener listener);
	
	/**
	 * This method removes any earlier registered listener. 
	 * No listener will be notified at all, after having called this method.
	 */
	public void removeAllIterationCompletedListeners();
	
	/**
	 * This method needs to be called, before trying to call compute. If the
	 * given data is incorrect, this method will throw an {@link InvalidDataException}.
	 * 
	 * @param nodes - any nodes within the network
	 * @param connections - any connections between those nodes
	 * @throws InvalidDataException - is thrown, if the given data is incorrect
	 */
	public void initialize(List<INode> nodes, List<IConnection> connections) throws InvalidDataException;
	
	/**
	 * This method starts the computation of the OutOfKilter. Make sure to have
	 * called {@link #initialize(List, List)} before invoking this method. 
	 * 
	 * @throws NotInitializedException - is thrown, if this method is called before {@link #initialize(List, List)}
	 * @throws InvalidDataException - is thrown, if the given data is invalid
	 * @throws InfiniteLoopException - is thrown, if the computation results in an infinite loop
	 */
	public void compute()  throws NotInitializedException, InvalidDataException, InfiniteLoopException;	
	
}
